﻿using System;
namespace TicTacToe
{
    public class CPlayer :ISubject
    {
        IObserver chessBoard = null;
        IPiece piece = null;
        public CPlayer(IPiece p){
            piece = p;
        }
        public void Attach(IObserver o){
            chessBoard = o;
        }
        public void Detach(IObserver o){
            if (chessBoard.Equals(o)){
                chessBoard = null;
            }
        }
        public void Notify(){
            chessBoard.Update();
        }

        public void Play(CGame game, int x, int y){
            game.SetChessBoard(x, y, piece);
            Notify();
        }
    }
}
